package com.aliengen.thingple.thingple.tag;

import android.util.Log;

import com.aliengen.thingple.thingple.tag.exception.InvalidTagException;

/**
 * This class is part of the Thingple mobile application for the CMC168 Handheld reader.
 *
 * Copyright AlienGen Limited 2016. All rights reserved.
 *
 * @author Timothé Mermet-Buffet <tim@aliengen.com>
 */
public class TruckTag extends Tag {

    protected int truck_id;

    public TruckTag(byte[] tag) throws InvalidTagException
    {
        super(tag);

        if(this.tagType != 0x02)
        {
            throw new InvalidTagException("Not truck tag!");
        }

        this.truck_id = ((b(12) & 0xFF) << 24) + ((b(13) & 0xFF) << 16) + ((b(14) & 0xFF) << 8) + (b(15) & 0xFF);
        Log.i("Truck Tag", "Truck ID: " + this.truck_id);
    }

    public int getTruckId() { return this.truck_id; }

    public String getPlateNumber()
    {
        return ""+this.truck_id;
    }
}
